<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    body {
      background: #ccc;
    }


    #div1 {
      width: 200px;
      height: 200px;
      background: orange;
      border: 4px solid white;
      box-shadow: 1px 1px 3px rgba(0, 0, 0, .3);
      position: absolute;
    }
  </style>
  <script>
    window.onload = function() {
      var oDiv = document.getElementById('div1');

      oDiv.onmousedown = function(ev) {
        var oEvent = ev || event;
        var posX =
          oEvent.clientX - oDiv.offsetLeft;
        var posY = oEvent.clientY -
          oDiv.offsetTop;

        if (oDiv.setCapture) {
          oDiv.onmousemove = mouseMove;
          oDiv.onmouseup = mouseUp;
          oDiv.setCapture();
        } else {
          document.onmousemove = mouseMove;
          document.onmouseup = mouseUp;
        }

        function mouseMove(ev) {
          var oEvent = ev || event;
          var l = oEvent.clientX - posX;
          var t = oEvent.clientY - posY;

          this.style.left = l + 'px';
          this.style.top = t + 'px';
        }

        function mouseUp() {
          this.onmousemove = null;
          this.onmouseup = null;
          if (this.releaseCapture) {
            this.releaseCapture();
          }
        }

        return false;

      };
    };
  </script>
</head>

<body>
  <div id="div1">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestiae ullam dolorem reiciendis, iure sapiente impedit doloremque corrupti officiis repellendus. Dolores harum nobis fugiat ipsum velit ratione, facilis deserunt repellendus ut.
  </div>
</body>

</html>
